<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="../vue.js"></script>

<body>
  <div id="app">
    <input type="text" v-focus="true">
  </div>

  <script>
    Vue.directive("focus", {
      // 针对当前元素的挂载点
      inserted(el, binding) {
        if (binding.value) {
          el.focus()
        }
      }
    })

    const vm = new Vue({
      // 整个页面的挂载点，针对于全局
      el: "#app",
    })
  </script>
</body>

</html>